

package at.fhj.itm.metadata.impl.postgres;

import at.fhj.itm.metadata.SqlNumeric;

/**
 *
 * @author Seuchter
 */
public class PostgresNumeric extends PostgresVariableLengthSqlType implements SqlNumeric{

    private int precision;
    private static final long VARHDRSZ = 4;
    public PostgresNumeric(String name, int size, boolean isArray,long oid, long typmod)
    {
        super(name, size, isArray, 0, oid);
        int p = (int) (((typmod - VARHDRSZ) >> 16) & 0xffff);
        int s = (int) ((typmod - VARHDRSZ) & (long)0xffff);

        this.length = s;
        this.precision = p;

    }

    @Override
    public String getTypePostfix()
    {
        return String.format("(%d,%d)", precision, length);
    }



    public int getPrecision()
    {
        return precision;
    }

}
